package com.ruoyi.jeeplus.modules.screen.fire_alarm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jeeplus.modules.screen.fire_alarm.domain.fire_alarm;
import com.ruoyi.jeeplus.modules.screen.fire_alarm.service.Ifire_alarmService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 消防Controller
 * 
 * @author ruoyi
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/fire_alarm/fire_alarm")
public class fire_alarmController extends BaseController
{
    @Autowired
    private Ifire_alarmService fire_alarmService;

    /**
     * 查询消防列表
     */
    @PreAuthorize("@ss.hasPermi('fire_alarm:fire_alarm:list')")
    @GetMapping("/list")
    public TableDataInfo list(fire_alarm fire_alarm)
    {
        startPage();
        List<fire_alarm> list = fire_alarmService.selectfire_alarmList(fire_alarm);
        return getDataTable(list);
    }

    /**
     * 导出消防列表
     */
    @PreAuthorize("@ss.hasPermi('fire_alarm:fire_alarm:export')")
    @Log(title = "消防", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, fire_alarm fire_alarm)
    {
        List<fire_alarm> list = fire_alarmService.selectfire_alarmList(fire_alarm);
        ExcelUtil<fire_alarm> util = new ExcelUtil<fire_alarm>(fire_alarm.class);
        util.exportExcel(response, list, "消防数据");
    }

    /**
     * 获取消防详细信息
     */
    @PreAuthorize("@ss.hasPermi('fire_alarm:fire_alarm:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fire_alarmService.selectfire_alarmById(id));
    }

    /**
     * 新增消防
     */
    @PreAuthorize("@ss.hasPermi('fire_alarm:fire_alarm:add')")
    @Log(title = "消防", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody fire_alarm fire_alarm)
    {
        return toAjax(fire_alarmService.insertfire_alarm(fire_alarm));
    }

    /**
     * 修改消防
     */
    @PreAuthorize("@ss.hasPermi('fire_alarm:fire_alarm:edit')")
    @Log(title = "消防", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody fire_alarm fire_alarm)
    {
        return toAjax(fire_alarmService.updatefire_alarm(fire_alarm));
    }

    /**
     * 删除消防
     */
    @PreAuthorize("@ss.hasPermi('fire_alarm:fire_alarm:remove')")
    @Log(title = "消防", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fire_alarmService.deletefire_alarmByIds(ids));
    }
}
